package com.caiyi.financial.nirvana.sms.gateway.http;

import com.caiyi.financial.nirvana.sms.enums.SmsMsgStatusEnum;
import com.caiyi.financial.nirvana.sms.queue.NotifyQueueEntity;
import com.caiyi.financial.nirvana.sms.queue.ReceiveMsgQueueEntity;
import com.caiyi.financial.nirvana.sms.queue.SendQueueEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MarketSampleGateway extends BaseGateway {

    private static final Logger logger = LoggerFactory.getLogger(MarketSampleGateway.class);

    @Override
    public void sendMessage(SendQueueEntity entity) {
        try {
            String[] split = entity.getMessageId().split(",");
            SmsMsgStatusEnum status = SmsMsgStatusEnum.SEND_SUCCESS;
            String result = info.getNotifyResult();
            if ("error".equalsIgnoreCase(result)) {
                status = SmsMsgStatusEnum.SEND_FAIL;
            }
            for (String messageId : split) {
                //模拟网关发送
                receiveReport(status.index, messageId, "0");
            }
            logger.info("MarketSampleGateway send success phone {}", entity.getPhone());
        } catch (Exception e) {
            logger.error("MarketSampleGateway error ! ", e);
        }
    }

    @Override
    public boolean notifyStatus(NotifyQueueEntity entity) {
        return true;
    }

    @Override
    public boolean receiveMsg(ReceiveMsgQueueEntity entity) {
        return true;
    }

    @Override
    public int queryBalance() {
        return 0;
    }
}
